import React, { PureComponent } from 'react';
import { Form, Input, Select, Modal } from 'antd';
const FormItem = Form.Item;
const Option = Select.Option;
class CustomizedForm extends PureComponent {
    constructor(props) {
        super(props);
    }
    okHandle = () => {
        const { form, handleUpdate, SelectObj } = this.props;
        form.validateFields((err, fieldsValue) => {
            if (err) return;
            // form.resetFields();
            const data = {
                ...fieldsValue,
                id: SelectObj.id,
                pid: SelectObj.pid
            }
            handleUpdate(data);
        });
    };
    render() {
        const { modalVisible, form, handleUpdateModalVisible ,SelectObj } = this.props;
        return (
            <Modal
                destroyOnClose //关闭时销毁 Modal 里的子元素
                title="修改组织信息"
                visible={modalVisible}
                onOk={this.okHandle}
                onCancel={() => handleUpdateModalVisible()}
            >
                <FormItem labelCol={{ span: 6 }} wrapperCol={{ span: 15 }} label="菜单名称">
                    {form.getFieldDecorator('name', {
                        rules: [{ required: true, message: '请输入菜单名称' }],
                        initialValue: SelectObj.name,
                    })(<Input placeholder="请输入" />)}
                </FormItem>
                {/* <FormItem labelCol={{ span: 6 }} wrapperCol={{ span: 15 }} label="是否最后一级">
                    {form.getFieldDecorator('leaf', {
                        rules: [{ required: true }],
                        initialValue: SelectObj.leaf,
                    })(
                        <Select style={{ width: "100%" }}>
                            <Option value={1}>不是最后一级</Option>
                            <Option value={0}>是最后一级</Option>
                        </Select>
                    )}
                </FormItem> */}
                <FormItem labelCol={{ span: 6 }} wrapperCol={{ span: 15 }} label="组织类型">
                    {form.getFieldDecorator('orgType', {
                        rules: [{ required: true }],
                        initialValue: SelectObj.orgType,
                    })(
                        <Select style={{ width: "100%" }}>
                            <Option value={1}>公司</Option>
                            <Option value={2}>车队</Option>
                        </Select>
                    )}
                </FormItem>
            </Modal>
        );
    }
}
const CreateForm = Form.create()(CustomizedForm);

export default CreateForm;
